﻿using System.Windows;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Controls.Maps;
using TaxiPlease.PhoneHelpers;
using Microsoft.Phone.Tasks;
using System;

namespace TaxiPlease
{
	public partial class MainPage : PhoneApplicationPage
	{
		public MainPage()
		{
			InitializeComponent();

			DataContext = App.ViewModel;
			this.map.Mode = new RoadMode();

			App.ViewModel.PropertyChanged += ViewModel_PropertyChanged;
		}

		private void ViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
		{
			if (e.PropertyName == "Location")
			{
				map.SetView(App.ViewModel.Location, 15.0);

				//string mapUri = "http://maps.googleapis.com/maps/api/staticmap?markers=color:orange%7Clabel:You%7C{0},{1}&center={0},{1}&zoom=17&size=450x350&sensor=false";
				//mapUri = string.Format(mapUri, App.ViewModel.Location.Latitude, App.ViewModel.Location.Longitude);
				//mapImage.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(mapUri));
			}
		}

		private void Settings_Click(object sender, System.EventArgs e)
		{
			NavigationService.Navigate(new Uri("/SettingsPage.xaml", UriKind.Relative));
		}

		private void About_Click(object sender, System.EventArgs e)
		{
			NavigationService.Navigate(new Uri("/SettingsPage.xaml?about=true", UriKind.Relative));
		}
	}
}